#include "ClassSkillProxy.h"



#include <CharacterItem.h>



#include <QDebug>



ClassSkillProxy::ClassSkillProxy(QObject *parent) :
    SimpleProxyModel(parent)
{
    addIncludeFilter("((\\S)+).Skill.((\\S)+)", SimpleProxyModel::RegExpFilter);
    addExcludeFilter(".Reference");

    addField(AbstractItem::NameData,tr("Class Skills"));
    addField(AbstractItem::IdData, tr("Selected"));
}



QVariant ClassSkillProxy::data(const QModelIndex &proxyIndex, int role) const
{
    if (!proxyIndex.isValid()) return QVariant();

    //qDebug() << Q_FUNC_INFO << proxyIndex.row() << proxyIndex.column();

    switch (proxyIndex.column())
    {
    case NameField:     return SimpleProxyModel::data(proxyIndex, role);
    case CheckedField:  break;
    default:            return QVariant();
    }

    if (role != Qt::DisplayRole) return QVariant();
    //if (role != Qt::CheckStateRole) return QVariant();


    QModelIndex sourceIndex = mapToSource(proxyIndex);
    if (!sourceIndex.isValid()) return "Invalid source";

    return sourceIndex.data(Qt::EditRole);
}


#if 0
QStringList ClassSkillProxy::classSkillReferences() const
{
    ItemModel* sourceModel = itemModel();
    if (!sourceModel) return QStringList();

    QModelIndexList classSkills = sourceModel->match(QModelIndex(), Qt::EditRole, "Class Skills", 1, Qt::MatchEndsWith);
    if (classSkills.isEmpty())
    {
        (void) new ItemGroup("Class Skills", sourceModel);
    }



}
#endif


